<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>安全支付</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <script src="/js/jquery-1.11.1.js"></script>
    <script src="http://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>
    <style type="text/css">
        body{padding: 0;margin:0;font-family: "microsoft yahei";}
        .pay-main{padding-top: 50px;padding-left: 20px;padding-bottom: 20px;}
        .pay-main img{margin: 0 auto;display: block;}
        .pay-main .lines{margin: 0 auto;text-align: center;font-size:14pt;margin-top: 10px;}
        .action{background:#15d447;padding: 10px 0;color:#ffffff;text-align: center;font-size:14pt;border-radius: 10px 10px; margin: 15px;}
        .action:focus{background:#4cb131;}
        .footer{position: absolute;bottom:0;left:0;right:0;text-align: center;padding-bottom: 20px;font-size:10pt;color:#aeaeae;}
        .footer .ct-if{margin-top:6px;font-size:8pt;}
    </style>
</head>
<body>
<#if errMsg??>
    <div class="conainer">
        <div class="pay-main">
            <img src="/images/err_icon.png"/>
            <div class="lines"><span id="tips">${errMsg}</span></div>
        </div>
        <br><br><div id='appexit' class='action'>关闭页面</div>
        <div class='footer'><div class='ct-if'></div></div>
    </div>
    <script>
        $(document).ready(function () {
            $('#appexit').click(function () {
                        AlipayJSBridge.call('exitApp');
                    }
            );
        });
    </script>
<#else>

<script>
    function returnApp() {
        AlipayJSBridge.call('confirm', {
            title: '支付提示',
            message: '确定要退出支付吗？',
            okButton: '是',
            cancelButton: '否'
        }, function (e) {
            if (e.ok) {
                AlipayJSBridge.call("exitApp")
            } else {
                pay()
            }
        })
    }

    function ready(a) {
        /*AlipayJSBridge.call('alert', {
            title: '错误',
            message: "",
            button: '确定'
        }, function(e) {
            AlipayJSBridge.call('exitApp');
        });*/
        window.AlipayJSBridge ? a && a() : document.addEventListener("AlipayJSBridgeReady", a, !1)
    }

    function pay() {
        AlipayJSBridge.call('setTitle', {title: '支付中心'});
        AlipayJSBridge.call("tradePay", {
            tradeNO: "${tradeNo}",
        }, function (result) {
            if (result.resultCode == '9000') {
                AlipayJSBridge.call("exitApp")
            } else {
                AlipayJSBridge.call('confirm', {
                    title: '支付提示',
                    message: '继续发起支付？',
                    okButton: '是',
                    cancelButton: '否'
                }, function (e) {
                    if (e.ok) {
                        pay()
                    } else {
                        returnApp()
                    }
                })
            }
        })
    }

    ready(pay);
</script>
</#if>
</body>
</html>
